Skip to content

Escape embedded quotes in CDL.rowToString instead of dropping them - #1101

Open
amalsaidov wants to merge 1 commit into
stleary:masterfrom
amalsaidov:fix/cdl-escape-embedded-quotes
Open

amalsaidov wants to merge 1 commit into
stleary:masterfrom
amalsaidov:fix/cdl-escape-embedded-quotes

Conversation

@amalsaidov

Copy link
Copy Markdown

CDL.toString/rowToString quotes a value when it contains the delimiter, a newline, or starts with a quote, but the quoted output silently removed every double quote in the value. This loses data and the result no longer round-trips, even though CDL.getValue already parses a doubled quote as an escaped quote (RFC 4180).

Repro:

JSONArray ja = new JSONArray().put(new JSONObject().put("a", "say \"hi\", ok"));
CDL.toString(ja);   // a\n"say hi, ok"\n   (quotes lost)

Fix: write an embedded quote as two quotes inside the quoted value; control characters are still omitted as before. Output is now a\n"say ""hi"", ok"\n, which CDL.toJSONArray parses back to the original value.

Added CDLTest.embeddedQuotesRoundTrip; full test suite passes.

@sonarqubecloud

sonarqubecloud Bot commented Dec 3, 2026

Copy link
Copy Markdown

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant